using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;

using GonzalesCore.CoreElements;
using GonzalesCore.CoreManagers;
using Kypris2.CoreElements;
using Kypris2.Utils;
using Jamila2.Tools;

public partial class GonzalesReportAcrualReport : System.Web.UI.Page
{
    #region Variables

    protected PrivateLoginSession CurrentPrivateSession = null;
    protected LogManager CurLogManager = null;
    protected DataView ResultView = null;

    #region ResultTable
    protected DataTable ResultTable
    {
        get
        {
            return (DataTable)ViewState["ResultTable"];
        }

        set
        {
            ViewState["ResultTable"] = value;
        }
    }
    #endregion

    #region UnexpectedError
    protected string UnexpectedError
    {
        get
        {
            return ViewState["UnexpectedError"].ToString();
        }

        set
        {
            ViewState["UnexpectedError"] = value;
        }
    }
    #endregion

    #region Download
    protected string Download
    {
        get
        {
            return ViewState["Download"].ToString();
        }

        set
        {
            ViewState["Download"] = value;
        }
    }
    #endregion

    #region ProperDateMessage
    protected string ProperDateMessage
    {
        get { return ViewState["ProperDateMessage"].ToString(); }
        set { ViewState["ProperDateMessage"] = value; }
    }
    #endregion

    #region GridViewHeader
    protected ArrayList GridViewHeader
    {
        get
        {
            return (ArrayList)ViewState["GridViewHeader"];
        }

        set
        {
            ViewState["GridViewHeader"] = value;
        }
    }
    #endregion

    #endregion

    #region Events

    protected void Page_Load(object sender, EventArgs e)
    {
        this.SessionCheck();

        this.Table_MessageBox.Visible = false;  // always default to false
        this.HyperLink_FileDownload.Visible = false;

        if (!IsPostBack)
        {
            this.PageComponentSetup();
            this.SwitchLanguage();
        }
    }
    protected void DropDownList_ByEntity_SelectedIndexChanged(object sender, EventArgs e)
    {
        using (CompanyManager CurCompanyManager = new CompanyManager(this.CurrentPrivateSession))
        {
            GonzalesCompanies ResultList = CurCompanyManager.GetCompanyByEntityID(this.DropDownList_ByEntity.SelectedValue);

            if (ResultList != null)
            {
                this.DropDownList_ByCompany.Items.Clear();
                this.DropDownList_ByCompany.Items.Add(new ListItem("", ""));

                for (int x = 0; x < ResultList.Count; x++)
                {
                    this.DropDownList_ByCompany.Items.Add(new ListItem(ResultList[x].CompanyName, ResultList[x].InternalID));
                }
            }
            else
            {
                this.CurLogManager.LogError("[GonzalesReportAcrualReport.DropDownList_ByEntity_SelectedIndexChanged] : Failed on CurCompanyManager.GetCompanyByEntityID('" + this.DropDownList_ByEntity.SelectedValue + "') : " + CurCompanyManager.ErrorMessage, this.CurrentPrivateSession.CurrentLoggedOnUser, LogInterface.System);
            }
        }

        #region Filter the company by Finance Admin
        if (this.CurrentPrivateSession.CurrentLoggedOnUser.IsFinanceAdmin)
        {
            using (UserManager CurUserManager = new UserManager(this.CurrentPrivateSession))
            {
                GonzalesCompanies ResultCompanies = CurUserManager.GetCompanyByFinanceAdmin(this.CurrentPrivateSession.CurrentLoggedOnUser.InternalID);
                if (ResultCompanies != null)
                {
                    int x = 1;

                    while (x < this.DropDownList_ByCompany.Items.Count)
                    {
                        bool Matched = false;

                        for (int y = 0; y < ResultCompanies.Count; y++)
                        {
                            if (ResultCompanies[y].InternalID.CompareTo(this.DropDownList_ByCompany.Items[x].Value) == 0)
                            {
                                Matched = true;
                                break;
                            }
                        }

                        if (!Matched)
                        {
                            this.DropDownList_ByCompany.Items.RemoveAt(x);
                        }
                        else
                        {
                            x++;
                        }
                    }
                }
            }
        }
        #endregion
    }
    protected void Button_Submit_Click(object sender, EventArgs e)
    {
        bool valid = true;
        StringBuilder ErrorMessageBuilder = new StringBuilder("<ul>");

        #region Date Validation

        if (this.TextBox_SubmittedDateFrom.Text.Length == 0 || this.TextBox_SubmittedDateTo.Text.Length == 0)
        {
            //ErrorMessageBuilder.AppendLine("<li>Please enter a date range</li>");
            //valid = false;
            this.TextBox_SubmittedDateFrom.Text = SwissArmy.DateConvert(DateTime.MinValue.AddYears(2000),this.CurrentPrivateSession.DateFormatInUse,"/");
            this.TextBox_SubmittedDateTo.Text = SwissArmy.DateConvert(DateTime.MaxValue,this.CurrentPrivateSession.DateFormatInUse, "/");
        }
        else
        {
            try
            {
                // try to convert to date
                DateTime Date1 = SwissArmy.DateConvert(this.TextBox_SubmittedDateFrom.Text, this.CurrentPrivateSession.CurrentLoggedOnUser.PreferedDateFormat);
                DateTime Date2 = SwissArmy.DateConvert(this.TextBox_SubmittedDateTo.Text, this.CurrentPrivateSession.CurrentLoggedOnUser.PreferedDateFormat);

                if (Date1 == DateTime.MinValue || Date2 == DateTime.MinValue)
                {
                    ErrorMessageBuilder.AppendLine("<li>"+ this.ProperDateMessage +"</li>");
                    valid = false;
                }
            }
            catch (Exception)
            {
                ErrorMessageBuilder.AppendLine("<li>" + this.ProperDateMessage + "</li>");
                valid = false;
            }

        }
        ErrorMessageBuilder.AppendLine("</ul>");
        #endregion

        if (this.DropDownList_ByCompany.SelectedIndex > 0 && valid)
        {
            this.LoadData();

            if (this.ResultTable != null)
            {
                //DataView ResultView = new DataView(this.ResultTable);
                this.BindData(this.ResultView);
            }
        }
        else
        {
            this.ShowErrorMessage(ErrorMessageBuilder.ToString());
        }
    }
    protected void Button_CSV_Click(object sender, EventArgs e)
    {
        this.Button_Submit_Click(sender, e);

        if (this.ResultTable != null)
        {
            string FileName = "Report-AccrualsReports-" + DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + ".csv";
            string ErrorMessage = "";

            // remove unnecessary column
            DataTable ResultTableForOutput = this.ResultView.ToTable();
            // thangnv added on 22,Jan./2015 ////////////////////////////////////
            if (!DropDownList_ByEntity.SelectedValue.Equals("28118"))
            {
                ResultTableForOutput.Columns.RemoveAt(18);
                ResultTableForOutput.Columns.RemoveAt(17);
                ResultTableForOutput.Columns.RemoveAt(16);
                ResultTableForOutput.Columns.RemoveAt(15);
            }
            //// end added //////////////////////////////////////////////////////

            ResultTableForOutput.Columns.RemoveAt(0);   // internal id            
            //ResultTableForOutput.Columns.RemoveAt(8);   // Ex Rate           
            //ResultTableForOutput.Columns.RemoveAt(5);   // internal id            
            //ResultTableForOutput.Columns.RemoveAt(5);   // internal id            
            //ResultTableForOutput.Columns.RemoveAt(5);   // internal id  
          
             //this.HyperLink_FileDownload.Text = Server.MapPath("ReportsOutput") + "\\" + FileName;
             //this.HyperLink_FileDownload.Visible = true;
             //   return;

            if (!ReportsGenerator.GenerateCSV(ResultTableForOutput, Server.MapPath("ReportsOutput") + "\\" + FileName, ref ErrorMessage))
            {
                string LogID = SwissArmy.UniqueID();
                this.CurLogManager.LogError(LogID, "[GonzalesReportAcrualReport.Button_CSV_Click] : Failed at ReportsGenerator.GenerateCSV : " + ErrorMessage, this.CurrentPrivateSession.CurrentLoggedOnUser, LogInterface.System);
                this.ShowErrorMessage(this.UnexpectedError + LogID);
            }
            else
            {
                this.HyperLink_FileDownload.Text = this.Download + FileName;
                this.HyperLink_FileDownload.NavigateUrl = "ReportsOutput/" + FileName;
                this.HyperLink_FileDownload.Visible = true;
            }
        }
    }

    #region OnRowCreated
    protected void OnRowCreated(object sender, GridViewRowEventArgs e)
    {
        if (DropDownList_ByEntity.SelectedValue.Equals("28118"))
        {
            GridViewResult.Columns[14].Visible = true;
            GridViewResult.Columns[15].Visible = true;
            GridViewResult.Columns[16].Visible = true;
            GridViewResult.Columns[17].Visible = true;
        }
        else
        {
            GridViewResult.Columns[14].Visible = false;
            GridViewResult.Columns[15].Visible = false;
            GridViewResult.Columns[16].Visible = false;
            GridViewResult.Columns[17].Visible = false;        
        }

        if (e.Row.RowType == DataControlRowType.Header)
        {
            TableCellCollection cells = e.Row.Cells;

            for (int i = 0; i < this.GridViewHeader.Count; i++)
            {
                cells[i].Text = this.GridViewHeader[i].ToString();
            }
        }
    }
    #endregion

    #endregion

    #region Customized Methods

    #region SessionCheck
    public void SessionCheck()
    {

        if (Session[GonzalesCommonNamingConvention.CurrentPrivateSession] != null)
        {
            this.CurrentPrivateSession = (PrivateLoginSession)Session[GonzalesCommonNamingConvention.CurrentPrivateSession];
            this.CurLogManager = new LogManager(this.CurrentPrivateSession);    // activate Log Manager
        }
        else
        {
            Response.Redirect(GonzalesErrorPageRedirect.SessionError);
        }

    }
    #endregion

    #region PageComponentSetup
    protected void PageComponentSetup()
    {
        // date
        //this.TextBox_SubmittedDateFrom.Attributes["onclick"] = "popUpCalendar(this, this, '" + SwissArmy.DateFormatForDisplay(this.CurrentPrivateSession.DateFormatInUse, "/") + "');";
        //this.TextBox_SubmittedDateTo.Attributes["onclick"] = "popUpCalendar(this, this, '" + SwissArmy.DateFormatForDisplay(this.CurrentPrivateSession.DateFormatInUse, "/") + "');";
        this.img_calendarFrom.Attributes["onClick"] = "popUpCalendar(this, document.getElementById('TextBox_SubmittedDateFrom') , '" + SwissArmy.DateFormatForDisplay(this.CurrentPrivateSession.DateFormatInUse, "/") + "');"; ;
        this.img_calendarTo.Attributes["onClick"] = "popUpCalendar(this, document.getElementById('TextBox_SubmittedDateTo') , '" + SwissArmy.DateFormatForDisplay(this.CurrentPrivateSession.DateFormatInUse, "/") + "');"; ;


        // setup entity
        if (this.CurrentPrivateSession.CurrentLoggedOnUser.IsPowerAdmin)
        {
            #region Power Admin
            using (EntityManager CurEntityManager = new EntityManager(this.CurrentPrivateSession))
            {
                MasterBaseCollection ResultList = CurEntityManager.GetAllEntity();
                if (ResultList != null)
                {
                    this.DropDownList_ByEntity.Items.Add(new ListItem("", ""));
                    for (int x = 0; x < ResultList.Count; x++)
                    {
                        this.DropDownList_ByEntity.Items.Add(new ListItem(ResultList[x].DisplayName, ResultList[x].InternalID));
                    }
                }
                else
                {
                    // display error
                    this.CurLogManager.LogError("[GonzalesReportAcrualReport.PageComponentSetup] : Failed on CurEntityManager.GetAllEntity() : " + CurEntityManager.ErrorMessage, this.CurrentPrivateSession.CurrentLoggedOnUser, LogInterface.System);

                }
            }
            #endregion
        }
        else
        {
            #region Finance Admin

            using (UserManager CurManager = new UserManager(this.CurrentPrivateSession))
            {
                MasterBaseCollection ResultList = CurManager.GetEntityByFinanceAdmin(this.CurrentPrivateSession.CurrentLoggedOnUser.InternalID);
                if (ResultList != null)
                {
                    for (int x = 0; x < ResultList.Count; x++)
                    {
                        this.DropDownList_ByEntity.Items.Add(new ListItem(ResultList[x].DisplayName, ResultList[x].InternalID));
                    }
                }
                else
                {
                    // display error
                    this.CurLogManager.LogError("[GonzalesAdminClaimantsListing.PageComponentSetup] : Failed on CurEntityManager.GetAllEntity() : " + CurManager.ErrorMessage, this.CurrentPrivateSession.CurrentLoggedOnUser, LogInterface.System);
                }
            }

            #endregion
        }

        this.DropDownList_ByEntity_SelectedIndexChanged(null, null);
    }
    #endregion

    #region SwitchLanguage
    protected void SwitchLanguage()
    {
        try
        {
            using (MultiLingualFactory CurLanguageFactory = MultiLingualEngine.GetMultiLingualFactory(this, this.CurrentPrivateSession.CurrentLoggedOnUser.PreferedLanguage.InternalID))
            {
                this.Label_ClaimStatus.Text = CurLanguageFactory.DisplayValue("ClaimStatus");
                this.Label_Company.Text = CurLanguageFactory.DisplayValue("Company");
                this.Label_DateRange.Text = CurLanguageFactory.DisplayValue("DateRange");
                this.Label_Entity.Text = CurLanguageFactory.DisplayValue("Entity");
                this.Label_Information.Text = CurLanguageFactory.DisplayValue("Information");
                this.Label_PageTitle.Text = CurLanguageFactory.DisplayValue("PageTitle");
                this.Label_Sorting.Text = CurLanguageFactory.DisplayValue("Sorting");
                this.Label_To.Text = CurLanguageFactory.DisplayValue("To");
                this.Button_CSV.Text = CurLanguageFactory.DisplayValue("CSV");
                this.Button_Submit.Text = CurLanguageFactory.DisplayValue("Submit");
                this.HyperLink_FileDownload.Text = CurLanguageFactory.DisplayValue("FileDownload");
                this.Download = CurLanguageFactory.DisplayValue("FileDownload");

                this.GridViewHeader = new ArrayList();
                this.GridViewHeader.Add(CurLanguageFactory.DisplayValue("RowNo"));
                this.GridViewHeader.Add(CurLanguageFactory.DisplayValue("EmployeeName"));
                this.GridViewHeader.Add(CurLanguageFactory.DisplayValue("EmployeeID"));
                this.GridViewHeader.Add(CurLanguageFactory.DisplayValue("ClaimID"));
                this.GridViewHeader.Add(CurLanguageFactory.DisplayValue("ProjectID"));
                this.GridViewHeader.Add(CurLanguageFactory.DisplayValue("Description"));
                this.GridViewHeader.Add(CurLanguageFactory.DisplayValue("ProfitCenter"));
                this.GridViewHeader.Add(CurLanguageFactory.DisplayValue("ExpenseDetailID"));
                this.GridViewHeader.Add(CurLanguageFactory.DisplayValue("AmountInUSD"));
                this.GridViewHeader.Add(CurLanguageFactory.DisplayValue("AmountInLocal"));
                this.GridViewHeader.Add(CurLanguageFactory.DisplayValue("ClaimSubmittedDate"));
                this.GridViewHeader.Add(CurLanguageFactory.DisplayValue("ClaimStatus2"));
                this.GridViewHeader.Add(CurLanguageFactory.DisplayValue("LastProcessedDate"));
                this.GridViewHeader.Add(CurLanguageFactory.DisplayValue("AgingDays"));
                // thangnv Added on 20/Jan./2015
                this.GridViewHeader.Add(CurLanguageFactory.DisplayValue("Purpose"));
                this.GridViewHeader.Add(CurLanguageFactory.DisplayValue("Tax"));
                this.GridViewHeader.Add(CurLanguageFactory.DisplayValue("Currency"));
                this.GridViewHeader.Add(CurLanguageFactory.DisplayValue("ExRate"));

                this.DropDownList_Status.Items.Add(new ListItem("",""));
                this.DropDownList_Status.Items.Add(new ListItem("Pending for Approver", ClaimManager.GetClaimStatusInString(GonzalesClaimHeader.TypeOfClaimStatus.Submitted)));
                this.DropDownList_Status.Items.Add(new ListItem("Pending for Higher Approver", ClaimManager.GetClaimStatusInString(GonzalesClaimHeader.TypeOfClaimStatus.Escalated)));
                this.DropDownList_Status.Items.Add(new ListItem("Pending for Authorizer", ClaimManager.GetClaimStatusInString(GonzalesClaimHeader.TypeOfClaimStatus.PendingForAuthorize)));
                this.DropDownList_Status.Items.Add(new ListItem("Pending for Finance Admin", ClaimManager.GetClaimStatusInString(GonzalesClaimHeader.TypeOfClaimStatus.PendingForFinanceVerification)));
                this.DropDownList_Status.Items.Add(new ListItem("Pending for Finance Verifier", ClaimManager.GetClaimStatusInString(GonzalesClaimHeader.TypeOfClaimStatus.FinanceApproval)));
                this.DropDownList_Status.Items.Add(new ListItem("Submitted for Payment", ClaimManager.GetClaimStatusInString(GonzalesClaimHeader.TypeOfClaimStatus.SubmittedForPayment)));
                this.DropDownList_Status.Items.Add(new ListItem("On Hold By Finance Admin", ClaimManager.GetClaimStatusInString(GonzalesClaimHeader.TypeOfClaimStatus.OnHold)));
     

                // sort by
                this.DropDownList_SortBy.Items.Add(new ListItem(CurLanguageFactory.DisplayValue("ClaimID"), "ClaimID"));
                this.DropDownList_SortBy.Items.Add(new ListItem(CurLanguageFactory.DisplayValue("ProfitCenter"), "ProfitCenter"));
                this.DropDownList_SortBy.Items.Add(new ListItem(CurLanguageFactory.DisplayValue("ExpenseDetailID"), "ExpenseDetailID"));                                                
                this.DropDownList_SortBy.Items.Add(new ListItem(CurLanguageFactory.DisplayValue("AmountInUSD"), "AmountInUSD"));
                this.DropDownList_SortBy.Items.Add(new ListItem(CurLanguageFactory.DisplayValue("EmployeeID"), "EmployeeID"));

                this.DropDownList_SortOrder.Items.Add(new ListItem(CurLanguageFactory.DisplayValue("ASC"), "ASC"));
                this.DropDownList_SortOrder.Items.Add(new ListItem(CurLanguageFactory.DisplayValue("DESC"), "DESC"));

                //claim status
                this.DropDownList_ClaimStatus.Items.Add(new ListItem(CurLanguageFactory.DisplayValue("AllUnclaimedItems"), "0"));
                this.DropDownList_ClaimStatus.Items.Add(new ListItem(CurLanguageFactory.DisplayValue("UnclaimedCashItems"), "1"));
                this.DropDownList_ClaimStatus.Items.Add(new ListItem(CurLanguageFactory.DisplayValue("UnclaimedCreditCardItems"), "2"));

                this.DropDownList_ReportType.Items.Add(new ListItem("Detail", "Detail"));
                this.DropDownList_ReportType.Items.Add(new ListItem("Summary", "Summary"));
            }
        }
        catch (Exception ex)
        {
            this.CurLogManager.LogError("[GonzalesReportGeneralClaimants.SwitchLanguage.EX] : " + ex.Message, this.CurrentPrivateSession.CurrentLoggedOnUser, LogInterface.User);
        }

    }
    #endregion

    #region ShowErrorMessage
    protected void ShowErrorMessage(string ErrorMessage)
    {
        this.Table_MessageBox.Visible = true;
        this.Table_MessageBox.Rows[0].Cells[0].Text = ErrorMessage;
        this.Table_MessageBox.Rows[0].Cells[0].CssClass = "ErrorBox";
    }
    #endregion

    #region ShowMessage
    protected void ShowMessage(string Message)
    {
        this.Table_MessageBox.Visible = true;
        this.Table_MessageBox.Rows[0].Cells[0].Text = Message;
        this.Table_MessageBox.Rows[0].Cells[0].CssClass = "MessageBox";
    }
    #endregion

    #endregion

    #region Data Operation

    #region LoadData
    protected void LoadData()
    {
        using (ReportsGenerator CurReportGenerator = new ReportsGenerator(this.CurrentPrivateSession))
        {
            if (this.DropDownList_ReportType.SelectedValue.CompareTo("Detail") == 0)
            {
                if ((this.ResultTable = CurReportGenerator.GetAccrualReport(this.CurrentPrivateSession.CurrentLoggedOnUser.PreferedLanguage.InternalID, this.DropDownList_ByCompany.SelectedValue, SwissArmy.DateConvert(this.TextBox_SubmittedDateFrom.Text, this.CurrentPrivateSession.CurrentLoggedOnUser.PreferedDateFormat), SwissArmy.DateConvert(this.TextBox_SubmittedDateTo.Text, this.CurrentPrivateSession.CurrentLoggedOnUser.PreferedDateFormat), this.DropDownList_ClaimStatus.SelectedItem.Value.ToString())) != null)
                {
                    this.ResultView = new DataView(this.ResultTable);

                    // filter
                    StringBuilder FilterBuilder = new StringBuilder();

                    if (this.DropDownList_Status.SelectedItem.Value.Length > 0)
                        FilterBuilder.Append(((FilterBuilder.Length > 0) ? " AND " : "") + "ClaimStatus = '" + this.DropDownList_Status.SelectedItem.Value + "'");


                    this.ResultView.RowFilter = FilterBuilder.ToString();
                    this.ResultView.Sort = this.DropDownList_SortBy.SelectedValue + " " + this.DropDownList_SortOrder.SelectedValue;

                }
                else
                {
                    string LogID = SwissArmy.UniqueID();
                    this.CurLogManager.LogError(LogID, "[GonzalesReportGeneralClaimants.LoadData] : Failed at CurReportGenerator.GetClaimantReportsByCompany('" + this.DropDownList_ByCompany.SelectedValue + "') : " + CurReportGenerator.ErrorMessage, this.CurrentPrivateSession.CurrentLoggedOnUser, LogInterface.System);
                    this.ShowErrorMessage("There is an unexpected error during the operation you carry out just now. Please contact the Administrator with this Refference ID: " + LogID);
                }
            }
            else
            {
                if ((this.ResultTable = CurReportGenerator.GetAccrualSummaryReport(this.CurrentPrivateSession.CurrentLoggedOnUser.PreferedLanguage.InternalID, this.DropDownList_ByCompany.SelectedValue, SwissArmy.DateConvert(this.TextBox_SubmittedDateFrom.Text, this.CurrentPrivateSession.CurrentLoggedOnUser.PreferedDateFormat), SwissArmy.DateConvert(this.TextBox_SubmittedDateTo.Text, this.CurrentPrivateSession.CurrentLoggedOnUser.PreferedDateFormat), this.DropDownList_ClaimStatus.SelectedItem.Value.ToString())) != null)
                {
                    this.ResultView = new DataView(this.ResultTable);

                    // filter
                    //StringBuilder FilterBuilder = new StringBuilder();

                    //if (this.DropDownList_ClaimStatus.SelectedItem.Value.CompareTo("Claimed Items") == 0)
                    //    FilterBuilder.Append(((FilterBuilder.Length > 0) ? " AND " : "") + "ClaimStatus = '7'");

                    //if (this.DropDownList_ClaimStatus.SelectedItem.Value.CompareTo("Unclaimed Items") == 0)
                    //    FilterBuilder.Append(((FilterBuilder.Length > 0) ? " AND " : "") + "ClaimStatus <> '7'");

                    //this.ResultView.RowFilter = FilterBuilder.ToString();
                    this.ResultView.Sort = this.DropDownList_SortBy.SelectedValue + " " + this.DropDownList_SortOrder.SelectedValue;

                }
                else
                {
                    string LogID = SwissArmy.UniqueID();
                    this.CurLogManager.LogError(LogID, "[GonzalesReportGeneralClaimants.LoadData] : Failed at CurReportGenerator.GetClaimantReportsByCompany('" + this.DropDownList_ByCompany.SelectedValue + "') : " + CurReportGenerator.ErrorMessage, this.CurrentPrivateSession.CurrentLoggedOnUser, LogInterface.System);
                    this.ShowErrorMessage("There is an unexpected error during the operation you carry out just now. Please contact the Administrator with this Refference ID: " + LogID);
                }
            }
        }
    }

    #endregion

    #region BindData

    private void BindData(DataView result)
    {
        this.GridViewResult.DataSource = result;
        this.GridViewResult.DataBind();
    }

    private void BindData(DataView result, int pageindex)
    {
        this.GridViewResult.PageIndex = pageindex;
        this.GridViewResult.DataSource = result;
        this.GridViewResult.DataBind();
    }

    #endregion

    #endregion
}
